#
# Make file to build the dbconnect wrapper components for the DBConnect API
# The dbconnect library will be built as both a static and dynamic lib to l
# link against.
#
# Copyright (c) Johnathan Ingram 2002
#
################################################################################

SHELL = /bin/sh

top_srcdir = @top_srcdir@
CC = @CC@
CXX = @CXX@
CPPFLAGS = -fPIC @CPPFLAGS@ -DDBCONNECTVER='"@dbconn_version@"'
CFLAGS = $(CPPFLAGS) @CFLAGS@ @OS_DEF@
LINKER_FLAGS = @LINKER_FLAGS@
IFLAGS = -I../base
AR = ar

SOURCES = dbconnect.cpp
OBJS = $(SOURCES:.cpp=.o)

# Update base sources from the Makefile.in in the src/base directory.
BASE_SOURCES = ../base/baseException.cpp ../base/simpleThreads.cpp \
  ../base/dlLoader.cpp ../base/configFile.cpp ../base/jDate.cpp \
  ../base/dbconnectExceptions.cpp ../base/baseConnection.cpp \
  ../base/baseQuery.cpp ../base/baseValue.cpp \
  ../base/baseFieldDescription.cpp ../base/hexDigest.cpp
BASE_OBJS = $(BASE_SOURCES:.cpp=.o)

# Only a dynamic version will be built as the drivers and app need the same symbols. Eg the client needs to trap an exception that the driver throws
all: dynamic
	cp -f ./libdbconnect-@dbconn_version@@SO_EXT@ $(top_srcdir)/lib
	cd $(top_srcdir)/lib && ln -sf libdbconnect-@dbconn_version@@SO_EXT@ libdbconnect@SO_EXT@ && cd -
	cp -f ./dbconnect.h $(top_srcdir)/include/dbconn
	cp -f ../base/*.h $(top_srcdir)/include/dbconn

dynamic: $(OBJS)
	gcc @SO_FLAG@ $(LINKER_FLAGS) -o libdbconnect-@dbconn_version@@SO_EXT@ $(OBJS) $(BASE_OBJS)


clean:
	rm -f *.o
	rm -f *.so
	rm -f *.a


%.o: %.cpp %.h
	$(CXX) -c $< $(CFLAGS) $(IFLAGS) -o $@

